<?php

	class Raid extends Eloquent {
		protected $table = 'raid';
    	public $timestamps = false;
        protected $primaryKey = "raid_id";

        public function scopeMembers($query) {
            $query->leftJoin("raid_members", "raid.raid_id", "=", "raid_members.raid_id");
        }

        public function scopeIsMember($query, $chars) {
            $charArray = array();

            foreach($chars as $char)
            {
                $charArray[] = $char->char_name;
            }
            return $query->whereRaw("raid_members.name IN ('" . implode("', '", $charArray)."')");
        }

        public function scopeDate($query) {
            $query->where("date", ">", date("d-m-Y H:i"));
        }
	}